package backend.inst;

import middleware.llvm.instruction.Instruction;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

/**
 * 注释
 *
 * @author 杨凯伟
 * @date 2024/11/27
 */
public class MipsComment extends MipsEntry {


    private final String comment;

    public MipsComment(String comment) {
        this.comment = comment;
    }

    public MipsComment(Instruction inst) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        PrintStream printStream = new PrintStream(outputStream, true);
        inst.dump(printStream);
        this.comment = outputStream.toString();
    }

    public String getComment() {
        return comment;
    }

    @Override
    public String toString() {
        return "# " + comment;
    }
}
